<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./echarts.min.js"></script>
</head>

<body>
    <div id="box" style="width:1000px;height:400px;border:1px solid black"></div>
</body>

</html>
<script>
    let myCharts = echarts.init(document.querySelector('#box'))

    let o = {
        title: {
            text: '标题',
            textStyle: {
                color: 'red'
            },
            left: 'center'
        },
        // xAxis: {
        //     type: 'category',
        //     boundaryGap: false

        // },
        // yAxis: {
        //     axisLine: {
        //         show: true
        //     }
        // },
        series: {
            type:'pie',
            data:[
                {name:'人生',value:10},
                {name:'游戏',value:30},
                {name:'军事',value:39},
            ],
            width:300,
            height:300,
            radius:40,
            itemStyle: {
                normal: {
                    color:(p)=>{
                        let data = ['red','green','blue'];
                        return data[p.dataIndex]
                    }
                }
            },
            left:100,
            top:100,
            label:{
                show:true
            }
        },
        // grid: {
        //         left: 30,
        //         right: 0,
        //         bottom: 30
        //     },
    };

    myCharts.setOption(o)
</script>